<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>工程概况</title>
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"
    />
    <link
      rel="stylesheet"
      href="../../layuiadmin/layui/css/layui.css"
      media="all"
    />
    <link
      rel="stylesheet"
      href="../../layuiadmin/style/admin.css"
      media="all"
    />
    <link
      rel="stylesheet"
      href="../../layuiadmin/style/style.css"
      media="all"
    />
    <style>
      body {
        position: relative;
      }
    </style>
  </head>
  <body>
    <div class="layui-fluid">
      <img
        src="../../layuiadmin/images/backPage.png"
        class="backPreviousPage"
      />
      <button class="layui-btn layuiadmin-btn-useradmin downLoadWord">
        下载
      </button>
      <button class="layui-btn layuiadmin-btn-useradmin deleteTechnical">
        删除
      </button>
      <!-- <button class="layui-btn layuiadmin-btn-useradmin backNextBtn">
      退回
    </button> -->
      <div class="time_axis">
        <div class="time_box">
          <div class="time_box_list">
            <ul class="time_horizontal"></ul>
          </div>
        </div>
      </div>
      <iframe id="pdf"></iframe>
      <div class="seePdfBox"></div>
    </div>
    <!-- 退回意见弹框 -->
    <script type="text/html" id="returnCommentsForm">
      <form lay-filter="returnCommentsForm" class="layui-form model-form">
        <div class="layui-form-item">
          <textarea
            placeholder=""
            class="layui-textarea"
            name="returnComments"
            style="min-height: 100px;"
          ></textarea>
        </div>
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">审核人:</label>
            <div class="layui-input-inline">
              <input
                type="text"
                name="reviewer"
                autocomplete="off"
                class="layui-input"
                id="Reviewer"
              />
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">联系方式:</label>
            <div class="layui-input-inline">
              <input
                type="tel"
                name="phone"
                autocomplete="off"
                class="layui-input"
                value="xxxxx"
              />
            </div>
          </div>
        </div>
        <!-- <div
          class="layui-form-item meetingScheduleBtn"
          style="text-align: center;"
        >
          <button class="layui-btn clearReturnComments" type="button">
            取消
          </button>
          <button class="layui-btn sureReturnComments" type="button">
            确定
          </button>
        </div> -->
      </form>
    </script>

    <script src="../../layuiadmin/modules/const_config.js"></script>
    <script src="../../layuiadmin/modules/jTools.js"></script>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script>
      layui
        .config({
          base: "../../layuiadmin/", //静态资源所在路径
          version: "20210514",
        })
        .extend({
          index: "lib/index", //主入口模块路径
        })
        .use(["index", "contlist", "table"], function () {
          var table = layui.table,
            $ = layui.$,
            form = layui.form,
            uuid = layui.data("uuid").key,
            type = layui.data("technicalType").key,
            reviewType = layui.data("reviewType").key,
            pipeline = layui.data("pipeline").key,
            pipelinesort = layui.data("pipelinesort").key,
            stationFlag = layui.data("stationFlag").key,
            stationArea = layui.data("stationArea").key;
          console.log(pipelinesort);
          var fileid = "";
          $(
            '#LAY-system-side-menu dd[data-name="opinionGeneration"]',
            parent.document
          ).addClass("layui-this");
          layer.load(2);
          $.ajax({
            type: "post",
            async: true, //异步执行
            url: base_url + "/Technical/saver",
            headers: {
              Accept: "application/json; charset=utf-8",
              Authorization: layui.sessionData("userToken").key,
            },
            contentType: "application/json",
            data: JSON.stringify({
              type: type,
              uuid: uuid,
              pipeline: pipeline,
              pipelinesort: pipelinesort,
              reviewType: reviewType,
              station: stationFlag,
              section: stationArea,
            }),
            success: function (data) {
              if (data.code == "200") {
                layer.closeAll("loading");
                if (data.data.length == 0) {
                  $("#pdf").attr(
                    "src",
                    "../../layuiadmin/web/viewer.html?file=''"
                  );
                } else {
                  saverData = data.data.reverse();
                  var html = "";
                  for (var i = 0; i < saverData.length; i++) {
                    fileid = saverData[i].fileId;
                    if (i == saverData.length - 1) {
                      html += `
                  <li class="time_horizontal_part"  data-id="${saverData[i].pdfName}" data-name="${saverData[i].fileName}" data-fileid="${saverData[i].fileId}">
                      <b class="active"></b>
                      ${saverData[i].createTime}<br/>
                  </li>`;
                      $("#pdf").attr(
                        "src",
                        "../../layuiadmin/web/viewer.html?file=" +
                          saverData[i].pdfName +
                          "&time=" +
                          new Date().getTime()
                      );
                    } else {
                      html += `
                  <li class="time_horizontal_part"  data-id="${saverData[i].pdfName}"  data-name="${saverData[i].fileName}" data-fileid="${saverData[i].fileId}">
                      <b></b>
                      ${saverData[i].createTime}<br/>
                  </li>`;
                    }
                  }
                }
              } else if (data.code == "500") {
                layer.closeAll("loading");
                layer.open({
                  title: '<i class="fa fa-plus"></i>&nbsp;退回意见',
                  type: 1,
                  fix: false,
                  skin: "layui-layer-rim",
                  // 加上边框
                  area: ["42%", "40%"],
                  // 宽高
                  content: $("#returnCommentsForm").html(),
                  btn: ["确认", "取消"],
                  success: function (layero, index) {
                    form.val("returnCommentsForm", {
                      reviewer: layui.sessionData("userName").key,
                      returnComments: data.message,
                    });
                  },
                });
              }
              $(".time_horizontal").append(html);
              $(".time_horizontal_part").on("click", function () {
                var uuid = $(this).attr("data-id");
                fileid = $(this).attr("data-fileid");
                $(this).children("b").addClass("active");
                $(this).siblings("li").children("b").removeClass("active");
                $("#pdf").attr(
                  "src",
                  "../../layuiadmin/web/viewer.html?file=" + uuid
                );
              });
              $(".downLoadWord").on("click", function () {
                window.location.href = $(".active").parent().attr("data-name");
              });
              $(".time_horizontal").scrollLeft(
                $(".time_horizontal")[0].scrollWidth
              );
            },
          });
          $(".deleteTechnical").on("click", function () {
            $.ajax({
              type: "post",
              async: true, //异步执行
              url: base_url + "/Technical/technicaldelect",
              headers: {
                Accept: "application/json; charset=utf-8",
                Authorization: layui.sessionData("userToken").key,
              },
              contentType: "application/json",
              data: JSON.stringify({ fileid: fileid }),
              success: function (data) {
                if ((data.type = "success")) {
                  var dom = document.querySelectorAll("ul>li");
                  var url = $(".active").parent().attr("data-id");
                  if (dom.length == 1) {
                    $("#pdf").attr("src", " ");
                  } else {
                    $.ajax({
                      type: "post",
                      async: true, //异步执行
                      url: base_url + "/Technical/permissionList",
                      headers: {
                        Accept: "application/json; charset=utf-8",
                        Authorization: layui.sessionData("userToken").key,
                      },
                      contentType: "application/json",
                      data: JSON.stringify({
                        uuid: uuid,
                        type: 0,
                        reviewType: reviewType,
                      }),
                      success: function (data) {
                        var data = data.data.reverse();
                        var html = "";
                        for (var i = 0; i < data.length; i++) {
                          if (i == data.length - 1) {
                            fileid = data[i].fileId;
                            html += `
                          <li class="time_horizontal_part" data-id="${data[i].pdfName}" data-fileid="${data[i].fileId}">
                              <b class="active"></b>
                              ${data[i].createTime}<br/>
                          </li>`;
                            $("#pdf").attr(
                              "src",
                              "../../layuiadmin/web/viewer.html?file=" +
                                data[i].pdfName +
                                ""
                            );
                          } else {
                            html += `
                          <li class="time_horizontal_part" data-id="${data[i].pdfName}" data-fileid="${data[i].fileId}">
                              <b></b>
                              ${data[i].createTime}<br/>
                          </li>`;
                          }
                        }
                        $(".time_horizontal").html(html);
                        $(".time_horizontal_part").on("click", function () {
                          var uuid = $(this).attr("data-id");
                          fileid = $(this).attr("data-fileid");
                          $(this).children("b").addClass("active");
                          $(this)
                            .siblings("li")
                            .children("b")
                            .removeClass("active");
                          $("#pdf").attr(
                            "src",
                            "../../layuiadmin/web/viewer.html?file=" + uuid
                          );
                        });
                        $(".time_horizontal").scrollLeft(
                          $(".time_horizontal")[0].scrollWidth
                        );
                      },
                    });
                  }
                  layer.confirm("确认删除吗?", function (index) {
                    $(".active").parent().remove();
                    layer.msg(data.message, { icon: 6 });
                  });
                } else {
                  layer.msg(data.message, { icon: 5 });
                }
              },
            });
          });
          $(".backPreviousPage").on("click", function () {
            $(this).attr("lay-href", "./pages/technicalReview.html");
          });
        });
    </script>
  </body>
</html>
